package cn.xzc.job.cocurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;

/**
 * @author 熊志聪
 * @Classname AsyncJobExecutor
 * @Description 异步任务执行器
 * @Date 2024/2/15 18:41
 */
public interface AsyncJobExecutor extends Executor {
    /**
     * Constant that indicates immediate execution.
     */
    long TIMEOUT_IMMEDIATE = 0;

    /**
     * Constant that indicates no time limit.
     */
    long TIMEOUT_INDEFINITE = Long.MAX_VALUE;


    /**
     * Submit a Runnable task for execution, receiving a Future representing that task.
     * The Future will return a {@code null} result upon completion.
     *
     * @param task the {@code Runnable} to execute (never {@code null})
     * @return a Future representing pending completion of the task
     */
    Future<?> submit(Runnable task);

    /**
     * Submit a Callable task for execution, receiving a Future representing that task.
     * The Future will return the Callable's result upon completion.
     *
     * @param task the {@code Callable} to execute (never {@code null})
     * @return a Future representing pending completion of the task
     */
    <T> Future<T> submit(Callable<T> task);
}
